#ifndef SNAKE_H
#define SNAKE_H

#include <list>
#include "snake/unit/snake_cell.h"
#include "common/direction.h"

class Snake {
    public:
    Direction direction;
    void reset(SnakeCell* head, Direction& direction);

    void newCell(SnakeCell* cell);

    int size() { return body.size(); }
    SnakeCell* getHead() { return body.front();  }
    SnakeCell* getTail() { return body.back(); }

    SnakeCell* popTail() { 
        if (body.empty()) {
            return nullptr; // 或者根据你的需求处理空列表的情况
        }

        SnakeCell* tail = body.back(); // 获取尾部元素
        body.pop_back();               // 移除尾部元素
        return tail;
     }

    private:
    std::list<SnakeCell*> body;
};

#endif